package com.rdzn.mall.base.util;

public class RedisKeyUtil {

    public static final String HOME_INDEX = "home-index";
    public static final String PRODUCT_LIST = "product-list";
    public static final String PRODUCT_DETAIL = "product-detail";
    public static final String MEMBER_INFO = "member-info";
    public static final String CATEGORY_LIST = "category-list";
    public static final String CATEGORY_PRODUCTS = "category-products";

    /**
     * redis的key
     * 形式为：
     * 表名:主键名:主键值:列名
     *
     * @param majorKeyValue 主键值
     * @param column 列名
     * @return
     */
    public static String getKeyWithColumn(String tableName, String majorKey, String majorKeyValue,String column){
        StringBuffer buffer = new StringBuffer();
        buffer.append(tableName).append(":");
        buffer.append(majorKey).append(":");
        buffer.append(majorKeyValue).append(":");
        buffer.append(column);
        return buffer.toString();
    }
    /**
     * redis的key
     * 形式为：
     * 表名:主键名:主键值
     *
     * @param majorKeyValue 主键值
     * @return
     */
    public static String getKey(String tableName, String majorKey, String majorKeyValue){
        StringBuffer buffer = new StringBuffer();
        buffer.append(tableName).append(":");
        buffer.append(majorKey).append(":");
        buffer.append(majorKeyValue).append(":");
        return buffer.toString();
    }
}
